package com.telchina.hrms.demand;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.telchina.nancy.core.dal.session.SqlSession;

/**
 * @project: hrms
 * 
 * @description:
 * 
 * @copyright: hrms
 * 
 * @author: kelvinjava
 * 
 * @version: v1.0
 * 
 * @createdate: 2012-5-10
 *
 */
@Component
public class DemandAL {

	private SqlSession<DemandPO,Long> sqlSession;

	public SqlSession<DemandPO, Long> getUserSqlSession() {
		return sqlSession;
	}
	@Autowired(required=true)
	@Resource(name="sqlSession")
	public void setUserSqlSession(SqlSession<DemandPO, Long> sqlSession) {
		this.sqlSession = sqlSession;
	}
	
	public void insert(DemandPO po){
		Long annalid=(Long) sqlSession.getValueBySqlId("getSeq");
		po.setAnnalid(annalid);
		sqlSession.insert(po);
	}
	
	public List<DemandPO> getDemands(DemandPO po){
		return sqlSession.query("getDemandsByModule", po);
	}
}
